<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="JavaScript" src="${ctx}/scripts/common/prototype.js"></script>
<script language="JavaScript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript"
	src="${ctx}/scripts/validation/validation.js"></script>

<link href="${ctx}/scripts/jscalendar-1.0/calendar-blue2.css"
	rel="stylesheet" type="text/css">
<script language="JavaScript"
	src="${ctx}/scripts/jscalendar-1.0/calendar.js"></script>
<script language="JavaScript"
	src="${ctx}/scripts/jscalendar-1.0/lang/calendar-en.js"></script>
<script language="JavaScript"
	src="${ctx}/scripts/jscalendar-1.0/calendar-setup.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript">
	//交易码改变时调用
	function businessCodeTypeChange(o){
		if(o.code == "002"){
			$('tpayMethod').style.display = "";
			$('tabSpan').style.display = "none";
		}else{
			$('tpayMethod').style.display = "none";
			$('tabSpan').style.display = "";
			$('payMethod').value="";
		}
	}

	var ACTION_URL = "${ctx}/charge_businessCodeAction.do?";
	var sourceValue;

	//新增
	function add(){
		var url= ACTION_URL + "method=add";
		var pars=$('fbussioncode').serialize();
		//校验
		var isTure= $("fbussioncode").fireEvent("onSubmit");
		//ajax提交
		if(isTure){
			closeORopenButton();
		//			alert(url);
			var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars, onComplete: showResponseAdd}
		                    );
		}
	}

	//新增操作的响应
	function showResponseAdd(result){
		var obj=findFrame('main');
		obj.reLoadIFrameList();
		closeORopenButton();
		ajaxSubmitException(result.responseText);
		windowClose();
	}



	//保存并新增
	function addAgain(){
		var url= ACTION_URL + "method=add";
		var pars=$('fbussioncode').serialize();
		//校验
		var isTure= $("fbussioncode").fireEvent("onSubmit");
		//ajax提交
		if(isTure){
			closeORopenButton();
		//			alert(url);
			var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars, onComplete: showResponseAddAgain}
		                    );
		}
	}

	//保存并新增操作的响应
	function showResponseAddAgain(result){
		var obj=findFrame('main');
		obj.reLoadIFrameList();
		closeORopenButton();
		ajaxSubmitException(result.responseText);
		document.location.reload();
	}


	//修改
	function edit(){
		var url= ACTION_URL + "method=edit";
		var pars=$('fbussioncode').serialize();
		//校验
		var isTure= $("fbussioncode").fireEvent("onSubmit");
		//ajax提交
		if(isTure){
			closeORopenButton();
		//			alert(url);
			var myAjax = new Ajax.Request(
		                    url,
		                    {method: 'post', parameters: pars, onComplete: showResponseEdit}
		                    );
		}
	}

	//修改操作的响应
	function showResponseEdit(result){
		var obj=findFrame('main');
		obj.reLoadIFrameListWithQuery();
		closeORopenButton();
		ajaxSubmitException(result.responseText);
		windowClose();
	}

	function init(){
		if(${isEdit}){
			$('head_title').innerText='${key.edit}';
			$('tsaveAndNew').style.display = "none"
			Event.observe('btn1_22','click',edit);
		}else{
			$('head_title').innerText='${key.add}';
			Event.observe('btn1_22','click',add);
		}
		Event.observe('btn1_42','click',addAgain);
		$('bizCode').validateUrl=ACTION_URL + "method=checkBizCode";
		if(getSelectedRadio()) getSelectedRadio().click();
		sourceValue=$('fbussioncode').serialize();
	}


	//如果内容有修改，则先提示是否关闭
	function closeWin(){
		var newValue=$('fbussioncode').serialize();
		if(sourceValue==newValue){
			windowClose();
		}else{
			AskConfirmTwo('${key.tipsForCloseWindow}',"editPageIframe","afterCloseDo","windowClose");
		}
	}

	//关闭窗口前执行的动作
	function afterCloseDo(){
		if(${isEdit}){
			edit();
		}else{
			add();
		}
	}

	//关闭或打开按钮事件
	function closeORopenButton(){
		$('window_footer').disabled= !$('window_footer').disabled;
		$('btn1_22').disabled= !$('btn1_22').disabled;
		$('btn1_32').disabled= !$('btn1_32').disabled;
		$('btn1_42').disabled= !$('btn1_42').disabled;
	}


	//获取当前所选定的交易类型的对象
	function getSelectedRadio(){
		var objs=document.getElementsByName('debitOrCredit');
		for(var i=0;i<objs.length;i++){
			if( objs[i].checked ){
				return objs[i];
			}
		}
	}
</script>

</head>

<body onload="init();">
<form id="fbussioncode" action="" class="required-validate" method="post">
<input type="hidden" name="oldBizCode" value="${businessCode.oldBizCode}">
<input type="hidden" name="keyword" value="${businessCode.keyword}">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="window_head_outBg">
		<table border="0" cellpadding="0" cellspacing="0">
			<tr>
				<td><img src="${ctx}/images/ico_Advance.gif" width="16"
					height="16" align="absmiddle"><span
					class="window_head_intext" id="head_title"></span></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="aux_header_line_1"></td>
	</tr>
	<tr>
		<td class="aux_header_line_2"></td>
	</tr>
	<tr>
		<td class="content">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td class="aux_outtable_color">
				<table width="100%" border="0" cellpadding="0" cellspacing="1"
					class="aux_intable_color">

					<tr>
						<td class="aux_intable_td1">${key.bizCode}：</td>
						<td class="aux_intable_require"><input
							name="bizCode" type="text" class="inputtext required  validate-char validate-ajax"  validateUrl="" relativeId="oldBizCode"  value="${businessCode.bizCode}"
							size="16" maxlength="36"></td>
					</tr>
					<tr>
						<td class="aux_intable_td1">${key.description}：</td>
						<td class="aux_intable_require"><input
							name="description" type="text" class="inputtext required validate-char " value="${businessCode.description}"
							size="16" maxlength="30"></td>
					</tr>
					<tr>
						<td colspan="2" class="aux_titletable">${key.debitOrCredit}：
							<mypms:Radio name="debitOrCredit"
							code="FEE_BUSINESS_CODE_DEBIT_OR_CREDIT"
							onclick="businessCodeTypeChange(this)"
							className="validate-one-required"
							selectValue="${businessCode.debitOrCredit}"
							/>
							<c:if test="${isEdit}">
							<div id="Layer1" noWrap=false style="position:absolute; width:360px; height:115px; z-index:1; left: 0px; top: 120px; filter:Alpha(opacity=0)">
							pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp<br>
							pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp<br>
							pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp<br>
							pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp<br>
							</div>
							</c:if>
						</td>
					</tr>
					<tbody colspan="2" width="100%" border="0" cellpadding="0"
						cellspacing="1" class="aux_intable_color" id="tabSpan"
						style="display:show">
						<tr>
							<td class="aux_intable_td1">&nbsp;</td>
							<td class="aux_intable_td2">&nbsp;</td>
						</tr>
					</tbody>

					<tbody colspan="2" width="100%" border="0" cellpadding="0"
						cellspacing="1" class="aux_intable_color" id="tpayMethod"
						style="display:none">
						<tr>
							<td valign="top" class="aux_intable_td1">${key.payMethod}：</td>
							<td class="aux_intable_require">
								<mypms:Sysrefcode name="payMethod"
								code="FEE_BUSINESS_CODE_PAY_METHOD"
								className="required"
								selectValue="${businessCode.payMethod}"
								/>
							</td>
						</tr>
					</tbody>
				</table>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="window_footer" id="window_footer">
		<table border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td>
				<table border="0" cellpadding="0" cellspacing="0" id="tsaveAndNew">
					<tr>
						<td class="buttonOffLeft" id="btn1_41"></td>
						<td class="buttonOffMiddle" id="btn1_42"
							onClick=""
							onMouseOver="btn_change_over(4)" onMouseOut="btn_change_out(4)"
							onblur="btn_change(4)"><img
							src="${ctx}/images/ico_saveandnewfile.gif" alt="" width="14"
							height="14" border="0" align="absbottom"> ${key.saveAndAdd}</td>
						<td class="buttonOffRight" id="btn1_43"></td>
					</tr>
				</table>
				</td>
				<td class="btn_between_space">&nbsp;</td>
				<td>
				<table border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td class="buttonOffLeft" id="btn1_21"></td>
						<td class="buttonOffMiddle" id="btn1_22" onClick="closewin();"
							onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)"
							onBlur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif"
							alt="" width="14" height="14" border="0" align="absbottom">
						${key.save}</td>
						<td class="buttonOffRight" id="btn1_23"></td>
					</tr>
				</table>
				</td>
				<td class="btn_between_space"></td>
				<td>
				<table border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td class="buttonOffLeft" id="btn1_31"></td>
						<td class="buttonOffMiddle" id="btn1_32" onClick="closeWin();"
							onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)"
							onBlur="btn_change(3)"><img
							src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14"
							border="0" align="absbottom"> ${key.close}</td>
						<td class="buttonOffRight" id="btn1_33"></td>
					</tr>
				</table>
				</td>
			</tr>
		</table>
		<p>&nbsp;</p>
		</td>
	</tr>
</table>
</form>
</body>
</html>
